package com.dgshanger.sanhxiaofeisc.mvp.model

import com.blankj.utilcode.util.EncryptUtils
import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.entity.CheckPwdEntity
import com.dgshanger.sanhxiaofeisc.entity.LoosePaymentEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.PayModelSettingContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/20.
 */
class PayModelSettingModel : PayModelSettingContract.Model {

    override fun goPay(shop_id: String?, pay_amount: String?, pay_type: String?, user_pay_pwd: String?
                       , user_wallet_amount: String?, user_integral_amount: String?
                       , httpObserver: XxBaseHttpObserver<LoosePaymentEntity>?) {
        AppApi.Api().shopLoosePayment(shop_id,pay_amount,pay_type, EncryptUtils.encryptMD5ToString(user_pay_pwd).toLowerCase(),user_wallet_amount
                , user_integral_amount)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)

    }

    override fun checkPwd(httpObserver: XxBaseHttpObserver<CheckPwdEntity>?) {
        AppApi.Api().checkPwd()
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }
}